import NextAuth from "next-auth";
import GitHubProvider from "next-auth/providers/github";
import { DrizzleAdapter } from "@auth/drizzle-adapter";
import { db } from "@/db/schema"; // 确保路径和导出一致

const handler = NextAuth({
  adapter: DrizzleAdapter(db),
  providers: [
    GitHubProvider({
      clientId: process.env.GITHUB_CLIENT_ID || "Iv23libvP1uYGkfqcU5y",
      clientSecret: process.env.GITHUB_CLIENT_SECRET || "bef6b78952f9af02934ec7decb2bf517d2ed2142",
    }),
  ],
  session: {
    strategy: "database",
  },
});

export { handler as GET, handler as POST };